home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
web
/
noweb
/
src
/
icon
/
texdefs.icn
< prev
next >
Wrap
Text File
|
1995-02-24
|
2KB
|
64 lines
#line 2 "texdefs.nw"
procedure main(args)
go()
end
#line 6 "texdefs.nw"
procedure postpass(name, arg)
static kind, idchars, definers, newcommand
initial { kind := "bogus"; idchars := &letters ++ '@'
definers := ["def", "newdimen", "newif", "newcount", "newwrite",
"newbox", "global\\def", "long\\def", "gdef" ]
newcommand := ["newcommand", "renewcommand"]
}
case name of {
"begin" : arg ? kind := tab(upto(' ')|0)
"text" : if kind == "code" then arg ? {
if =("\\" || !definers || "\\") then
writedefn("\\" || (tab(many(idchars)) | move(1)))
else if =("\\" || !newcommand || "{") then
writedefn(tab(upto('}')))
}
}
return
end
procedure prepass(name, arg)
if name == "end" then writedefn(&null) # force newline
end
#line 1 "defns.nw"
procedure go()
local line
while line := read() do {
apply(prepass, line)
write(line)
apply(postpass, line)
}
end
procedure apply(pass, line)
line ? (="@" & pass(tab(upto(' ')|0), if =" " then tab(0) else &null))
end
#line 17 "defns.nw"
procedure writedefn(defn, locl)
static indextext
initial indextext := ""
if /defn then
*indextext > 0 &
#line 30 "defns.nw"
{ # write("@index nl") # don't!
indextext := ""
}
#line 22 "defns.nw"
else {
if *indextext + *defn > 65 then
#line 30 "defns.nw"
{ # write("@index nl") # don't!
indextext := ""
}
#line 24 "defns.nw"
write(if \locl then "@index localdefn" else "@index defn ", defn)
indextext ||:= " " || defn
}
return
end